import Cookies from 'js-cookie'

/**
 * COOKIES
 * @type {{set(*, *): void, get(*): *}}
 */
export const COOKIES = {
    set(key,val){
        Cookies.set(key,val)
    },
    get(key){
        return Cookies.get(key)
    }
}
/**
 * SESSION
 * @type {{set(*, *): void, get(*): string, remove(*): void}}
 */
export const SESSION = {
    get(key){
        return sessionStorage.getItem(key)
    },
    set(key,val){
        sessionStorage.setItem(key,val)
    },
    remove(key){
        sessionStorage.removeItem(key)
    }
}
/**
 * LOCAL
 * @type {{set(*, *): void, get(*): string, remove(*): void}}
 */
export const LOCAL = {
    get(key){
        return localStorage.getItem(key)
    },
    set(key,val){
        localStorage.setItem(key,val)
    },
    remove(key){
        localStorage.removeItem(key)
    }
}
/**
 * TOKEN
 * @type {{set(*, *): void, getUserToken(): *, get(*): void, setUserToken(*): void, userTokenKey: string}}
 */
export const TOKEN = {
    userTokenKey:'token',
    get(key){
        return COOKIES.get(key)
    },
    set(key,item){
        COOKIES.set(key,item)
    },
    getUserToken(){
        return this.get(this.userTokenKey)
    },
    setUserToken(val){
        console.log('setToken',val)
        this.set(this.userTokenKey,val)
    }
}
